package com.demo.order.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 商品服务Feign客户端
 * 用于调用商品服务的接口
 */
@FeignClient(name = "product-service", fallback = ProductFeignClientFallback.class)
public interface ProductFeignClient {

    /**
     * 扣减商品库存
     * @param productId 商品ID
     * @param quantity 扣减数量
     * @return 操作结果
     */
    @PostMapping("/api/product/reduce-stock/{productId}")
    Map<String, Object> reduceStock(@PathVariable("productId") Long productId, 
                                   @RequestParam("quantity") Integer quantity);

    /**
     * 回滚商品库存
     * @param productId 商品ID
     * @param quantity 回滚数量
     * @return 操作结果
     */
    @PostMapping("/api/product/rollback-stock/{productId}")
    Map<String, Object> rollbackStock(@PathVariable("productId") Long productId, 
                                     @RequestParam("quantity") Integer quantity);

    /**
     * 获取商品信息
     * @param productId 商品ID
     * @return 商品信息
     */
    @PostMapping("/api/product/info/{productId}")
    Map<String, Object> getProductInfo(@PathVariable("productId") Long productId);
}